#include "stdafx.h"
#include "ApkButtonManager.h"
#include "Log.h"

CApkButtonManager::CApkButtonManager()
{
}

CApkButtonManager::~CApkButtonManager()
{
}

void CApkButtonManager::add(CApkButtonEx *item)
{
	mTestItemVector.push_back(item);
}

void CApkButtonManager::resetAll()
{
	for (size_t i=0; i<mTestItemVector.size(); i++)
	{
		mTestItemVector[i]->Reset();
	}
}

int CApkButtonManager::GetBtnBgColor(int btnID)
{
	for (size_t i=0; i<mTestItemVector.size(); i++)
	{
		if(mTestItemVector[i]->GetResourceID() == btnID)
		{
			return mTestItemVector[i]->GetBgColor();
		}
	}

	return RGB(236, 233, 216);
}

BOOL CApkButtonManager::ContainID(int btnID)
{
	for (size_t i=0; i<mTestItemVector.size(); i++)
	{
		if(mTestItemVector[i]->GetResourceID() == btnID)
		{
			return TRUE;
		}
	}

	return FALSE;
}

BOOL CApkButtonManager::GetTestResult(CString &strErrCode)
{
	BOOL isTestOk = TRUE;
	for (size_t i=0; i<mTestItemVector.size(); i++)
	{
		if(mTestItemVector[i]->GetState() != CApkButtonEx::APK_BTN_STATE_PASS)
		{
			log_printf("CMesErrorCode mErrorCodeArray[%d]=%s BTN=%s\n", i, (char *)(LPCTSTR)mMesErrorCode.GetErrorCodeByIndex(i), mTestItemVector[i]->GetErrorCode());
			strErrCode = strErrCode+ mMesErrorCode.GetErrorCodeByIndex(i)+",";
			isTestOk = FALSE;
		}
	}

	return isTestOk;
}